package com.seagox.chat.chat.controller;

import com.seagox.chat.chat.entity.Calendar;
import com.seagox.chat.chat.service.ICalendarService;
import com.seagox.chat.common.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 日历
 */
@RestController
@RequestMapping("/calendar")
public class CalendarController {

    @Autowired
    private ICalendarService calendarService;

    /**
     * 查询全部
     */
    @GetMapping("/queryByDate/{day}")
    public ResultData queryByDate(@PathVariable String day, String userId) {
        return calendarService.queryByDate(userId, day);
    }

    /**
     * 新增
     */
    @PostMapping("/insert")
    public ResultData insert(@Valid Calendar calendar) {
        return calendarService.insert(calendar);
    }

    /**
     * 更新
     */
    @PostMapping("/update")
    public ResultData update(@Valid Calendar calendar) {
        return calendarService.update(calendar);
    }

    /**
     * 删除
     */
    @PostMapping("/delete/{id}")
    public ResultData delete(@PathVariable String id) {
        return calendarService.delete(id);
    }

}
